package com.ocom.payconfig.dao;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;

import com.ocom.common.entity.payconfig.EntityCloudComputingInfo;
import com.ocom.common.vo.payconfig.cloudcomputing.CloudComputingVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;


@Mapper
public interface IDaoCloudComputing extends BaseMapper<EntityCloudComputingInfo> {
    @Select({"<script>",
            "SELECT p.com_id, p.dept_id, d.dept_name, p.p_id, p.p_code, p.p_name, p.p_sex, ",
            "s.userName, s.password, s.use_info, s.customer_info, s.end_time, s.balance, ",
            "s.remark, s.status, s.update_user, s.update_time, s.check_user, s.check_time ",
            "FROM personnel_info p ",
            "LEFT JOIN cloud_computing_info s ON p.com_id = s.com_id AND p.p_id = s.p_id ",
            "LEFT JOIN dept_info d ON p.com_id = d.com_id AND p.dept_id = d.dept_id ",
            "WHERE p.com_id = #{cloudComputingVo.comId} AND p.status = 0 ",
            "<if test='cloudComputingVo.pCode != null'>AND p.p_code = #{cloudComputingVo.pCode}</if> ",
            "<if test='cloudComputingVo.pName != null'>AND p.p_name LIKE concat('%', #{cloudComputingVo.pName}, '%')</if> ",
            "<if test='cloudComputingVo.pId != null'>AND p.p_id = #{cloudComputingVo.pId}</if> ",
            "<if test='cloudComputingVo.deptId != null'>AND p.dept_id = #{cloudComputingVo.deptId}</if> ",
            "<if test='cloudComputingVo.userName != null'>AND s.username LIKE concat('%', #{cloudComputingVo.userName}, '%')</if> ",
            "<if test='cloudComputingVo.status != null'>AND s.status = #{cloudComputingVo.status}</if> ",
            "ORDER BY s.update_time DESC",
            "</script>"})
    List<CloudComputingVo> selectPersonnelInfoWithConditions(@Param("cloudComputingVo") CloudComputingVo cloudComputingVo);


}
